angular.module('buyblockModule', ['ionic'])
	.controller('buyblockCtrl',  ["$scope","$http","loadmore",function($scope,$http,lo) {
		lo.load()
		.then(function(res){
			$scope.banners = res.data.data.banner;
			$scope.goodsList = res.data.data.goodsList;
		});
		$scope.loadMore = function(){
			lo.loadmores()
			.then(function(res){
				$scope.goodsList = res.data.data.goodsList;
				$scope.$broadcast('scroll.infiniteScrollComplete');			
			});
		}
	
}])
.factory("loadmore",function($http){
	var page = 0
	var load = function(){
	return $http.get("/icy/m.php?fromPageId=0&pageSize=20&page=1&cardId=177&method=goods.getListByCard&page="+page)
		.then(function(res){
			return res
		})
	};
	var loadmores = function(){
		page += 1
		return $http.get("/icy/m.php?fromPageId=0&page=1&cardId=177&method=goods.getListByCard",{
			params:{
				pageSize:20*page
			}
		})
		.then(function(res){
			return res		
		})
	};
	return {
		load:load,
		loadmores:loadmores
	}
})
